using System.Collections.Generic;
using Webcrawler;
namespace Graph
{
    //FEN 2008.10.28 Using generics
    /// <summary>
    /// Represents a vertex in a directed graph
    /// </summary>
    public class Vertex
    {
        private Link _link;
        private bool _mark;
        private IList<Edge> _edgeList;

        public Vertex(Link link)
        {
            _mark = false;
            this._link = link;
            _edgeList = new List<Edge>();
        }

        public override string ToString()//For debugging purposes
        {
            return _link.Name + "  " + Mark;
        }

        public Link Link
        {
            get
            {
                return _link;
            }
            set
            {
                _link = value;
            }
        }

        public bool Mark
        {
            get
            {
                return _mark;
            }
            set
            {
                _mark = value;
            }
        }

        public IList<Edge> Edges() //must return a List in order to be able to remove edges
        {
            return _edgeList;
        }

        public void AddEdge(Vertex to)
        {
            Edge e = new Edge(this, to);
            _edgeList.Add(e);
        }

        public int OutDegree()
        {
            return _edgeList.Count;
        }

        public void RemoveEdge(Edge e)
        {
            _edgeList.Remove(e);
        }
        
    }
}
